package com.steak.dynamic.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * @author 刘牌
 * @Title:
 * @date 2022-04-2319:49
 */
@Component
public class OrderService implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher applicationEventPublisher;

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.applicationEventPublisher = applicationEventPublisher;
    }

    public void placeOrder(OrderDTO orderDTO){
        System.out.println("place order "+orderDTO);
        this.applicationEventPublisher.publishEvent(new OrderEvent<>(this, orderDTO));
    }
}
